#pragma once
#include <QObject>
#include <QMutex>
#include <QWaitCondition>
#include <atomic>
#include <opencv2/opencv.hpp>

class CameraWorker : public QObject
{
    Q_OBJECT
public:
    explicit CameraWorker(int cameraId,
                          QMutex *mutex,
                          QWaitCondition *trigger,
                          QObject *parent = nullptr);
    void stop();

public slots:
    void capture();

signals:
    void frameReady(const QImage &img);
    void finished();

private:
    int  m_cameraId;
    std::atomic<bool> m_running{true};
    QMutex *m_mutex;
    QWaitCondition *m_trigger;
};
